﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Controls.DataVisualization.Charting;
using System.Windows.Media;
using System.Windows.Browser;
using System.Windows.Markup;
using Orid.Management.Statistics.OperatorUnitMangement.Common.ExportAsPNG;
using System.Reflection;

namespace Orid.Management.Statistics.OperatorUnitMangement
{
    public class SimData
    {
        public string SN { get; set; }
        public decimal ScoreA { get; set; }
        public decimal ScoreB { get; set; }
    }

    public partial class DataGridTest : UserControl
    {
        PagedCollectionView pcv;
        StringBuilder strFilter = new StringBuilder();
        List<Employees> returnedValue = new List<Employees>();


        public DataGridTest()
        {
            InitializeComponent();
            this.btnFilter2.Click += new RoutedEventHandler(btnFilter2_Click);

            this.Loaded += new RoutedEventHandler(MainPage_Loaded);

            this.btnFilter.Click += new RoutedEventHandler(btnFilter_Click);

            this.btnRestore.Click += new RoutedEventHandler(btnRestore_Click);

            this.btnMyFilter.Click += new RoutedEventHandler(btnMyFilter_Click);

            this.btnFilterStart.Click += new RoutedEventHandler(btnFilterStart_Click);

            System.Windows.ResourceDictionary dic = new ResourceDictionary();
            
            dic.Add("1", "a");
            dic.Add("2", "b");
            dic.Add("3", "c");
            dic.Add("4", "d");
            dic.Add("5", "e");

            Dictionary<string, string> FieldDictTest = new Dictionary<string, string>();
            
            FieldDictTest.Add("1","a");
            FieldDictTest.Add("2", "b");
            FieldDictTest.Add("3", "c");

            FieldDictTest.Values.ToList<string>();

            this.datagridDic.ItemsSource = dic.Values;



        }


        /// <summary>
        /// Gets the columns.
        /// </summary>
        /// <returns></returns>
        public List<string> GetColumns()
        {

            List<string> c = new List<string>();
            c.Add("员工号");
            c.Add("姓名");
            c.Add("年龄");
            c.Add("部门");
            c.Add("级别");
            return c;

        }


        public List<Employees> GetEmployees()
        {

            List<Employees> returnedValue = new List<Employees>();

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 1, EmployeeName = "张三", EmployeeAge = 23, DepartmentName = "3,911", Level = "初级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 2, EmployeeName = "李四", EmployeeAge = 24, DepartmentName = "2277", Level = "中级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 3, EmployeeName = "王五", EmployeeAge = 25, DepartmentName = "1254", Level = "中级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 4, EmployeeName = "赵六", EmployeeAge = 26, DepartmentName = "58.2%", Level = "初级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 5, EmployeeName = "钱七", EmployeeAge = 27, DepartmentName = "32.0%", Level = "中级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 6, EmployeeName = "孙八", EmployeeAge = 28, DepartmentName = "14804", Level = "初级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 7, EmployeeName = "小张", EmployeeAge = 26, DepartmentName = "9936", Level = "中级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 8, EmployeeName = "小钱", EmployeeAge = 45, DepartmentName = "6826", Level = "高级" });

            return returnedValue;

        }

        #region 

        public List<Employees> GetEmployeesline1()
        {

           List<Employees> returnedValue = new List<Employees>();


            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 2, EmployeeName = "7/9", EmployeeAge = 15.79, DepartmentName = "2277", Level = "中级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 5, EmployeeName = "7/12", EmployeeAge = 64.71, DepartmentName = "32.0%", Level = "中级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 6, EmployeeName = "7/13", EmployeeAge = 68.61, DepartmentName = "14804", Level = "初级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 7, EmployeeName = "7/14", EmployeeAge = 56.38, DepartmentName = "9936", Level = "中级" });


            return returnedValue;

        }

        public List<Employees> GetEmployeesline2()
        {

            List<Employees> returnedValue = new List<Employees>();

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 1, EmployeeName = "7/8", EmployeeAge = 15.79, DepartmentName = "3,911", Level = "初级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 2, EmployeeName = "7/9", EmployeeAge = 67.12, DepartmentName = "2277", Level = "中级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 3, EmployeeName = "7/10", EmployeeAge = 64.94, DepartmentName = "1254", Level = "中级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 4, EmployeeName = "7/11", EmployeeAge = 71.56, DepartmentName = "58.2%", Level = "初级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 5, EmployeeName = "7/12", EmployeeAge = 68.79, DepartmentName = "32.0%", Level = "中级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 6, EmployeeName = "7/13", EmployeeAge = 72.32, DepartmentName = "14804", Level = "初级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 7, EmployeeName = "7/14", EmployeeAge = 68.66, DepartmentName = "9936", Level = "中级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 8, EmployeeName = "7/15", EmployeeAge = 71.25, DepartmentName = "6826", Level = "高级" });

            return returnedValue;

        }

        public List<Employees> GetEmployeesline3()
        {

            List<Employees> returnedValue = new List<Employees>();

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 1, EmployeeName = "7/8", EmployeeAge = 20.00, DepartmentName = "3,911", Level = "初级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 2, EmployeeName = "7/9", EmployeeAge = 9.34, DepartmentName = "2277", Level = "中级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 3, EmployeeName = "7/10", EmployeeAge = 7.39, DepartmentName = "1254", Level = "中级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 4, EmployeeName = "7/11", EmployeeAge = 10.20, DepartmentName = "58.2%", Level = "初级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 6, EmployeeName = "7/13", EmployeeAge = 8.56, DepartmentName = "14804", Level = "初级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 7, EmployeeName = "7/14", EmployeeAge = 8.74, DepartmentName = "9936", Level = "中级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 8, EmployeeName = "7/15", EmployeeAge = 9.54, DepartmentName = "6826", Level = "高级" });

            return returnedValue;

        }

        /// <summary>
        /// Gets the employeesline4.
        /// </summary>
        /// <returns></returns>
        public List<Employees> GetEmployeesline4()
        {

            List<Employees> returnedValue = new List<Employees>();

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 30, EmployeeName = "7/14", EmployeeAge = 26, DepartmentName = "9936", Level = "中级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 5, EmployeeName = "7/15", EmployeeAge = 45, DepartmentName = "6826", Level = "高级" });
           
            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 10, EmployeeName = "7/8", EmployeeAge = 23, DepartmentName = "3,911", Level = "初级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 16, EmployeeName = "7/13", EmployeeAge = 28, DepartmentName = "14804", Level = "初级" });

            return returnedValue;

        }

        public List<Employees> GetEmployeesline5()
        {

            List<Employees> returnedValue = new List<Employees>();

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 1, EmployeeName = "7/8", EmployeeAge = 23, DepartmentName = "3,911", Level = "初级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 2, EmployeeName = "7/9", EmployeeAge = 24, DepartmentName = "2277", Level = "中级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 3, EmployeeName = "7/10", EmployeeAge = 25, DepartmentName = "1254", Level = "中级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 4, EmployeeName = "7/11", EmployeeAge = 26, DepartmentName = "58.2%", Level = "初级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 5, EmployeeName = "7/12", EmployeeAge = 27, DepartmentName = "32.0%", Level = "中级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 6, EmployeeName = "7/13", EmployeeAge = 28, DepartmentName = "14804", Level = "初级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 7, EmployeeName = "7/14", EmployeeAge = 26, DepartmentName = "9936", Level = "中级" });

            returnedValue.Add(new Employees() { SelectIDCheck = false, EmployeeID = 8, EmployeeName = "7/15", EmployeeAge = 45, DepartmentName = "6826", Level = "高级" });

            return returnedValue;

        }


        #endregion

        /// <summary>
        /// Handles the Loaded event of the MainPage control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {

            GetRestore();

            List<SimData> data = new List<SimData>();


            //以亂數摸擬資料
            Random rnd = new Random();
            for (int i = 0; i < 100; i++)
            {
                data.Add(new SimData()
                {
                    SN = i.ToString("00000"),
                    ScoreA = 100 - rnd.Next(199),
                    ScoreB = 100 - rnd.Next(199)
                });
            }
            
            /*
             * 使用DataGridTextColumn，在DataGrid.LoadingRow事件中，
             * 利用DataGridTextColumn.GetCellContent(DataGridRowEventArgs.Row)的方式取出儲存格中
             * 的視覺元素(對DataGridTextColumn而言，就是TextBlock)，將其轉型為TextBlock，
             * DataGridRowEventArgs.Row.DataContext可取得資料物件，用Reflection的技巧取出ScoreA或ScoreB，
             * 再依其正負調整TextBlock的Foreground屬性。Reflection的地方可以用switch或if配合Hardcoding取代
             * (例如: if (c.Header.ToString() == "ScoreA") v = sd.ScoreA;)，或者可以用Binding + Converter方式
             * 將前景色跟資料屬性值綁在一起
             * */


            #region 方法2: 利用DataGrid的LoadingRow事件加工
            SolidColorBrush normal = new SolidColorBrush(Colors.Green);
            SolidColorBrush negative = new SolidColorBrush(Colors.Red);
            dg2.LoadingRow += (s, o) =>
            {
                //o為DataGridRowEventArgs
                SimData sd = o.Row.DataContext as SimData;
                //巡過所有欄位，找出Score*
                foreach (DataGridColumn c in dg2.Columns)
                {
                    if (c.Header.ToString().Contains("Score"))
                    {
                        //動態取得TextBlock物件
                        TextBlock tb =
                            c.GetCellContent(o.Row) as TextBlock;
                        //o.Row.DataContext就是SimData, 可以Hard-Coding去取sd.ScoreA/B
                        //這裡則示範用Reflection法取Binding目標欄位值
                        PropertyInfo pi = sd.GetType().GetProperty(
                            (c as DataGridTextColumn).Binding.Path.Path);
                        decimal v = Convert.ToDecimal(pi.GetValue(sd, null));
                        tb.Foreground = (v >= 0) ? normal : negative;
                    }
                }
            };
            dg2.ItemsSource = data;
            #endregion




        }



        void btnRestore_Click(object sender, RoutedEventArgs e)
        {

            GetRestore();

        }



        void btnFilter_Click(object sender, RoutedEventArgs e)
        {

            if (cbColumns.SelectedIndex != -1 && tbValue.Text != "")
            {

                switch (cbColumns.SelectedIndex)
                {

                    case 0:

                        pcv.Filter = new Predicate<object>(FilterEmployeeID);

                        break;

                    case 1:

                        pcv.Filter = new Predicate<object>(FilterEmployeeName);

                        break;

                    case 2:

                        pcv.Filter = new Predicate<object>(FilterEmployeeAge);

                        break;

                    case 3:

                        pcv.Filter = new Predicate<object>(FilterDepartmentName);

                        break;

                    case 4:

                        pcv.Filter = new Predicate<object>(FilterLevel);

                        break;
                }
            }

        }

        //过滤器函数

        public bool FilterEmployeeID(object t)
        {

            Employees em = t as Employees;

            return (em.EmployeeID == Convert.ToInt32(tbValue.Text) && em.EmployeeAge >=40);

        }



        public bool FilterEmployeeName(object t)
        {

            Employees em = t as Employees;

            return (em.EmployeeName == Convert.ToString(tbValue.Text) );

        }



        public bool FilterEmployeeAge(object t)
        {

            Employees em = t as Employees;

            return (em.EmployeeAge >= Convert.ToInt32(tbValue.Text));//这里用的是大于等于条件

        }



        public bool FilterDepartmentName(object t)
        {

            Employees em = t as Employees;

            return (em.DepartmentName == Convert.ToString(tbValue.Text));
        }



        public bool FilterLevel(object t)
        {

            Employees em = t as Employees;

            return (em.Level == Convert.ToString(tbValue.Text));

        }



        //重置信息

        public void GetRestore()
        {

            pcv = new PagedCollectionView(GetEmployees());

            dgEmployee11.ItemsSource = pcv;

            cbColumns.ItemsSource = GetColumns();
            Employee em=new Employee();

            cbColumns.SelectedIndex = 0;

            tbValue.Text = String.Empty;


            LineSeriesEmp.Axes.Clear();
            LineSeriesEmp.Series.Clear();


             #region 折线图#region 折线图
             Action<Chart> chartModifier1 = (chart) =>
             {
                 //----横---
                 DisplayAxis dataAxis = new CategoryAxis { Orientation = AxisOrientation.X, Title=" 单位(￥)",FontStyle = FontStyles.Normal, ShowGridLines = true };
                 LineSeriesEmp.Axes.Add(dataAxis);

                 //---竖---
                 IAxis valueAxis = new LinearAxis { Orientation = AxisOrientation.Y, Title=" 单位(￥)",FontStyle = FontStyles.Normal, Minimum = 0,Maximum = 100,ShowGridLines = true };
                 LineSeriesEmp.Axes.Add(valueAxis);
             };
             chartModifier1(LineSeriesEmp);

            //自定义Y轴
             IRangeAxis rangeAxis = new LinearAxis
             {
                 Orientation = AxisOrientation.Y,//指定为Y轴 
                 Location = AxisLocation.Right,//呈现在右侧
                 Title = "Range Axis",
                 FontSize = 12,
                 //设置轴的区间
                 Minimum = 0,

                 //设置颜色
                 //背景区域色
                 //Background = new SolidColorBrush(Color.FromArgb(80, 255, 255, 100)),
                 //Y轴字体色
                 Foreground = new SolidColorBrush(Colors.Black),
             };

             ColumnSeries series = new ColumnSeries()
             {
                 ItemsSource = GetEmployeesline4(),
                 IndependentValueBinding = new System.Windows.Data.Binding("EmployeeName"),
                 DependentValueBinding = new System.Windows.Data.Binding("EmployeeID"),
                 Foreground = new SolidColorBrush(Colors.Black),
                 Title = "Contrl Limit",
                 DependentRangeAxis = rangeAxis,//绑定的RangeAxis会自动显示在Chart中
             };
             LineSeriesEmp.Series.Add(series);

             ColumnSeries lineSeries3 = new ColumnSeries()
             {

                 ItemsSource = GetEmployeesline5(),
                 IndependentValueBinding = new System.Windows.Data.Binding("EmployeeName"),
                 DependentValueBinding = new System.Windows.Data.Binding("EmployeeID"),
                 Foreground = new SolidColorBrush(Colors.Green),
                 Title = "名刺",
                 DependentRangeAxis = rangeAxis,//绑定的RangeAxis会自动显示在Chart中
             };
             LineSeriesEmp.Series.Add(lineSeries3);


             LineSeries lineSeries1 = new LineSeries();
             lineSeries1.ItemsSource = GetEmployeesline1();
             //----横---
             lineSeries1.IndependentValueBinding = new System.Windows.Data.Binding("EmployeeName");
             //---坚---
             lineSeries1.DependentValueBinding = new System.Windows.Data.Binding("EmployeeAge");

             lineSeries1.Foreground = new SolidColorBrush(Colors.Red);
             lineSeries1.Title = "KYBER NOTE";
             LineSeriesEmp.Series.Add(lineSeries1);

             LineSeries lineSeries2 = new LineSeries();
             lineSeries2.ItemsSource = GetEmployeesline2();
             lineSeries2.IndependentValueBinding = new System.Windows.Data.Binding("EmployeeName");
             lineSeries2.DependentValueBinding = new System.Windows.Data.Binding("EmployeeAge");
             lineSeries2.Foreground = new SolidColorBrush(Colors.Blue);
             lineSeries2.Background = new SolidColorBrush(Colors.Red);

             lineSeries2.Title = "手書き";
             LineSeriesEmp.Series.Add(lineSeries2);


             #endregion

             string headDate = "7-10";
             DataGridTextColumn templateColumn = new DataGridTextColumn();
            headDate +="\r  木";
            templateColumn.Header = headDate;

            templateColumn.Binding = new Binding("DepartmentName");
            dgEmployee11.Columns.Add(templateColumn);





            DateTime DateTime1=Convert.ToDateTime("2010-07-28");

            DateTime DateTime2=Convert.ToDateTime("2010-08-02");

            int a = DateDiff(DateTime1, DateTime2);

            string DateTime3=DateTime1.AddDays(1).ToString("yyyy-MM-dd");



            List<Employee> employeelist = new List<Employee>();
            //Employee em = new Employee();
            em.FirstName = "1";
            em.LastName = "01";
            em.Diclist.Add(0, "a");
            em.Diclist.Add(1, "b");
            em.Diclist.Add(2, "c");
            employeelist.Add(em);

            em = new Employee();
            em.FirstName = "2";
            em.LastName = "02";
            em.Diclist.Add(0, "c");
            em.Diclist.Add(1, "d");
            em.Diclist.Add(2, "c");
            employeelist.Add(em);


            List<string[]> classToList = new List<string[]>();

            int dicnum = employeelist[0].Diclist.Count;
            int classmun = employeelist[0].GetType().GetProperties().Length - 1;
            //列数
            int m = 0;
            foreach (Employee forem in employeelist)
            {
                String[] stradd = new String[dicnum + classmun];

                stradd[m++] = forem.FirstName;
                stradd[m++] = forem.LastName;
                for (int j = 0; j < forem.Diclist.Count; j++)
                {
                    stradd[m++] = forem.Diclist[j];
                }
                classToList.Add(stradd);
                m = 0;
            }

            pcv = new PagedCollectionView(classToList);

            dgEmployee11.ItemsSource = pcv;
            
        }


        Dictionary<string, string> FieldDict = new Dictionary<string, string>(); 
        
        

        /// <summary>
        /// 将datagrid的表头名和邦定名与控件关联
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void btnFilter2_Click(object sender, RoutedEventArgs e)
        {

            this.spPanel.Children.Clear();

            //***取邦定名和表头名***
            var v = from p in dgEmployee.Columns 
                    where p is DataGridBoundColumn 
                    select p;


            foreach (DataGridBoundColumn column in v.ToList())
            {
                //string fieldname = column.Binding.Path.Path;
                //string strname = column.Header.ToString();

                // *******TextBlock*TextBox**********//
                //
                TextBlock tb = new TextBlock();
                TextBox tbox = new TextBox();
                ComboBox cbox = new ComboBox();

                tb.Text = column.Header.ToString(); // 表头名
                tb.Margin = new Thickness(10, 0, 0, 0);

                tbox.Margin = new Thickness(2, 0, 0, 0);
                tbox.Width = 75;
                tbox.Height = 25;
                tbox.Tag = column.Binding.Path.Path; // 邦定名

                cbox.Name = column.Binding.Path.Path; // 邦定名
                cbox.Margin = new Thickness(2, 0, 0, 0);
                cbox.Width = 75;
                cbox.Height = 25;
                cbox.Items.Add(" = ");
                cbox.Items.Add(" >= ");
                cbox.Items.Add(" <= ");
                cbox.Items.Add(" <> ");
                cbox.Items.Add(" LIKE ");
                cbox.SelectedIndex = 0;
               
                this.spPanel.Children.Add(tb);
                this.spPanel.Children.Add(cbox);
                this.spPanel.Children.Add(tbox);

                // ***************************************** 
                
            }
        }

        /// <summary>
        /// 组合过滤条件的按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void btnMyFilter_Click(object sender, RoutedEventArgs e)
        {
            //string strFilter = string.Empty;

            //throw new NotImplementedException();
            if (this.spPanel.Children.Count > 0) 
            {
                foreach (var item in this.spPanel.Children) 
                {
                    //itme.GetType() == typeof(TextBox)
                    if (item is TextBox)
                    {
                        //如果有过滤条件
                        if (!string.IsNullOrEmpty(((TextBox)item).Text.ToString())) 
                        {
                            //找到对应的COMBOBOX,并取出条件值。
                           object comboboxObject = FindName(((TextBox)item).Tag.ToString());
                           string str = ((ComboBox)comboboxObject).SelectionBoxItem.ToString();

                           strFilter.Append(((TextBox)item).Tag.ToString() + str + ((TextBox)item).Text);
                           strFilter.Append(" AND ");
                        }
                    }
                }

                MessageBox.Show(strFilter.ToString());
            }

        }
        

        void btnFilterStart_Click(object sender, RoutedEventArgs e)
        {

            pcv.Filter = new Predicate<object>(FilterFun);


            ParameterExpression c = System.Linq.Expressions.Expression.Parameter(typeof(Employees), "c");
            System.Linq.Expressions.Expression condition = System.Linq.Expressions.Expression.Constant(false);

            System.Linq.Expressions.Expression con = System.Linq.Expressions.Expression.Call(
                System.Linq.Expressions.Expression.Property
                              (
                                  c,
                                  typeof(Employees).GetProperty("EmployeeName")),
                                  typeof(string).GetMethod("StartsWith", new Type[] { typeof(string) }),
                                  System.Linq.Expressions.Expression.Constant("张")//表示字符串常量
                              );
            condition = System.Linq.Expressions.Expression.Or(con, condition);  

            System.Linq.Expressions.Expression<Func<Employees, bool>> end =
            System.Linq.Expressions.Expression.Lambda<Func<Employees, bool>>(condition, new ParameterExpression[] { c });

            //var v = returnedValue.Where(end);

            //var results = returnedValue.Where(b => b.EmployeeAge > 25 || b.EmployeeName == "Hello");

            List<object> myObjects = new List<object>();



          // var results = returnedValue.Where("EmployeeAge == @0 || EmployeeName == @1", new object[] { 5, "Hello" });

            //var results = returnedValue.Where(myQuery, myObjects.ToArray());

        }
        

        public bool FilterFun(object t)
        {
            //em.EmployeeID == Convert.ToInt32(tbValue.Text) && em.EmployeeAge >=40

            Employees em = t as Employees;

            return (em.DepartmentName == Convert.ToString(tbValue.Text));


        }

        /// <summary>
        /// 计算两个日期相差多少天
        /// </summary>
        /// <param name="DateTime1">开始日期</param>
        /// <param name="DateTime2">结束日期</param>
        /// <returns>相差天数</returns>
        private int DateDiff(DateTime DateTime1, DateTime DateTime2)
        {
            int dateDiff =0;
            try
            {
                TimeSpan ts1 = new TimeSpan(DateTime1.Ticks);
                TimeSpan ts2 = new TimeSpan(DateTime2.Ticks);
                TimeSpan ts = ts1.Subtract(ts2).Duration();
                //dateDiff = ts.Days.ToString() + "天" + ts.Hours.ToString() + "小时" + ts.Minutes.ToString() + "分钟" + ts.Seconds.ToString() + "秒";
                dateDiff = Convert.ToInt32(ts.Days);

            }
            catch
            {
            }
            return dateDiff;
        }

        //图形导出的用法
        private void button_Click(object sender, RoutedEventArgs e)
        {
            ElementToPNG eTP = new ElementToPNG();
            //eTP.ShowSaveDialog(myChart);
        }

        
    }

    ///// <summary>
    ///// TEXTBOX值对应过滤值
    ///// </summary>
    //public class FilterParameters 
    //{
    //    /// <summary>
    //    /// 绑定字段名
    //    /// </summary>
    //    string bingdingName = string.Empty;
    //    public string BingdingName
    //    {
    //        get { return bingdingName; }
    //        set { bingdingName = value; }
    //    }

    //    /// <summary>
    //    /// 对应字段名的过滤条件
    //    /// </summary>
    //    string filterCondition = string.Empty;
    //    public string FilterCondition
    //    {
    //        get { return filterCondition; }
    //        set { filterCondition = value; }
    //    }

      
 


    public class Employees
    {

        public bool SelectIDCheck = false;

        public int EmployeeID { get; set; }

        public string EmployeeName { get; set; }

        public double EmployeeAge { get; set; }

        public string DepartmentName { get; set; }

        public string Level { get; set; }

    }

    public class EmployeesJob
    {

        public DateTime EmployeeDateTime1 { get; set; }

        public int EmployeeName1 { get; set; }

        public DateTime EmployeeDateTime2 { get; set; }

        public int EmployeeName2 { get; set; }


        public DateTime EmployeeDateTime3 { get; set; }

        public int EmployeeName3 { get; set; }


        public DateTime EmployeeDateTime4 { get; set; }

        public int EmployeeName4 { get; set; }
      

    }

    public class Employee
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }

        Dictionary<int, string> diclist = new Dictionary<int, string>();

        public Dictionary<int, string> Diclist
        {
            get { return diclist; }
            set { diclist = value; }
        }
       

    }

    

}
